/*   1:    */ package gov.sat.tax.fwsk.wlrz;
/*   2:    */ 
/*   3:    */ import com.htxx.security.cipher.CommonBean;
/*   4:    */ import com.htxx.security.cipher.DESCipher;
/*   5:    */ import com.htxx.security.cipher.RSACipher;
/*   6:    */ import java.io.PrintStream;
/*   7:    */ import java.math.BigInteger;
/*   8:    */ import java.util.StringTokenizer;
/*   9:    */ 
/*  10:    */ public class TranslateParaCmdBean
/*  11:    */ {
/*  12: 17 */   private static BigInteger n = new BigInteger(
/*  13: 18 */     "161bcca7146f9e489635bc62a12bb21402d1a2a31b17aef2177807f77181ced9", 
/*  14: 19 */     16);
/*  15: 20 */   private static BigInteger e = new BigInteger("05", 16);
/*  16: 22 */   private String Cryptext = "";
/*  17:    */   
/*  18:    */   public String doDecrypt(String Cryptograph)
/*  19:    */   {
/*  20:    */     try
/*  21:    */     {
/*  22: 31 */       System.out.println("[info] " + this.Cryptext);
/*  23:    */       String DES;
/*  24:    */       int DataLen;
/*  25:    */       String RSA;
/*  26:    */       String DES;
/*  27: 34 */       if (Cryptograph.startsWith("HX"))
/*  28:    */       {
/*  29: 35 */         Cryptograph = Cryptograph.substring(2);
/*  30: 36 */         int RSALen = Integer.parseInt(Cryptograph.substring(0, 8), 16) * 2;
/*  31: 37 */         int DataLen = Integer.parseInt(Cryptograph.substring(8, 16), 16);
/*  32: 38 */         String RSA = Cryptograph.substring(24, 24 + RSALen);
/*  33: 39 */         DES = Cryptograph.substring(24 + RSALen, Cryptograph.length());
/*  34:    */       }
/*  35:    */       else
/*  36:    */       {
/*  37: 41 */         int RSALen = Integer.parseInt(Cryptograph.substring(0, 4), 16) * 2;
/*  38: 42 */         DataLen = Integer.parseInt(Cryptograph.substring(4, 8), 16);
/*  39: 43 */         RSA = Cryptograph.substring(12, 12 + RSALen);
/*  40: 44 */         DES = Cryptograph.substring(12 + RSALen, Cryptograph.length());
/*  41:    */       }
/*  42: 47 */       RSACipher rsa = new RSACipher();
/*  43: 48 */       rsa.setN(n);
/*  44: 49 */       rsa.setE(e);
/*  45: 50 */       byte[] keyCipher = CommonBean.hex2byte(RSA);
/*  46: 51 */       byte[] keyFormer = rsa.Encrypt(keyCipher);
/*  47: 52 */       DESCipher des = new DESCipher(keyFormer);
/*  48:    */       
/*  49: 54 */       byte[] desCipher = CommonBean.hex2byte(DES);
/*  50:    */       
/*  51: 56 */       byte[] dataCipher = new byte[8];
/*  52: 57 */       byte[] dataFormer = new byte[8];
/*  53: 58 */       byte[] data = new byte[DataLen];
/*  54: 61 */       for (int i = 0; i < desCipher.length; i += 8)
/*  55:    */       {
/*  56: 63 */         for (int j = 0; j < 8; j++)
/*  57:    */         {
/*  58: 65 */           dataCipher[j] = desCipher[(i + j)];
/*  59: 66 */           dataFormer[j] = 0;
/*  60:    */         }
/*  61: 69 */         des.decrypt(dataCipher, 0, dataFormer, 0);
/*  62:    */         int EndPos;
/*  63:    */         int EndPos;
/*  64: 71 */         if ((DataLen != desCipher.length) && 
/*  65: 72 */           (i + 8 == desCipher.length)) {
/*  66: 74 */           EndPos = 8 - (desCipher.length - DataLen);
/*  67:    */         } else {
/*  68: 78 */           EndPos = 8;
/*  69:    */         }
/*  70: 81 */         for (int j = 0; j < EndPos; j++) {
/*  71: 83 */           data[(i + j)] = dataFormer[j];
/*  72:    */         }
/*  73:    */       }
/*  74: 87 */       this.Cryptext = new String(data);
/*  75: 88 */       System.out.println("[info] " + this.Cryptext);
/*  76: 89 */       return this.Cryptext;
/*  77:    */     }
/*  78:    */     catch (Exception e)
/*  79:    */     {
/*  80: 93 */       System.out.println("TranslateParaCmdBean.doDecrypt error：" + 
/*  81: 94 */         e.toString());
/*  82:    */     }
/*  83: 98 */     return null;
/*  84:    */   }
/*  85:    */   
/*  86:    */   public String getParameter(String Para)
/*  87:    */   {
/*  88:111 */     String s = null;String sName = null;String sValue = null;
/*  89:    */     try
/*  90:    */     {
/*  91:115 */       StringTokenizer paramTokens = new StringTokenizer(this.Cryptext, "&");
/*  92:117 */       while (paramTokens.hasMoreTokens())
/*  93:    */       {
/*  94:119 */         s = paramTokens.nextToken();
/*  95:120 */         sName = s.substring(0, s.indexOf("="));
/*  96:122 */         if (Para.equals(sName))
/*  97:    */         {
/*  98:124 */           sValue = s.substring(s.indexOf("=") + 1, s.length());
/*  99:125 */           break;
/* 100:    */         }
/* 101:    */       }
/* 102:    */     }
/* 103:    */     catch (Exception e)
/* 104:    */     {
/* 105:131 */       System.out.println("TranslateParaCmdBean.getParameter error: " + 
/* 106:132 */         e.toString());
/* 107:    */       
/* 108:134 */       return null;
/* 109:    */     }
/* 110:137 */     return sValue;
/* 111:    */   }
/* 112:    */ }


/* Location:           D:\htjs\document\wsrz\WsrzEjbInf\
 * Qualified Name:     gov.sat.tax.fwsk.wlrz.TranslateParaCmdBean
 * JD-Core Version:    0.7.0.1
 */